package org.rudenko.horo;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class HoroscopActivity extends Activity {
    public Intent pageView;
    public static Button btns[]= new Button[12];
    public static int currentSignId;
    public static final int[] signsId={R.id.aries,R.id.taurus,R.id.gemini,R.id.cancer,R.id.leo,R.id.virgo,R.id.libra,
    	R.id.scorpio,R.id.sagittarius,R.id.capricorn,R.id.aquarius,R.id.pisces};
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
 	   int newConfig = getResources().getConfiguration().orientation;	 
 	   if (newConfig== Configuration.ORIENTATION_LANDSCAPE) 
 	   {		   //ландшафтная ориентация
 		   setContentView(R.layout.h_signs_layout);
 	   } 
 	   else if (newConfig == Configuration.ORIENTATION_PORTRAIT)
 	   { 		   //портретная ориентация
 		   setContentView(R.layout.v_signs_layout);
 	   }  
        pageView  = new Intent(this, ViewPageActivity.class);        
        
        for(int i=0;i<btns.length;i++){
        	btns[i] = (Button)findViewById(signsId[i]);
        	btns[i].setOnClickListener(new OnClickListener(){

        		public void onClick(View v) {
        			for(int i=0;i < signsId.length;i++){ if ( signsId[i] == v.getId()) currentSignId=i;}        			
        			pageView.putExtra(ViewPageActivity.ID, currentSignId);
        			startActivity(pageView);
        		}
        	
        	});
        	
/////////////////////////END ONCREATE/////////////////////////////////////////        
        }
    }
    
}